#ifndef __UXML_DOCUMENT_H__
#define __UXML_DOCUMENT_H__

#include "zCore.h"
#include "xNonCopyable.h"
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <string>

namespace ck
{
	namespace xml
	{
		class Element;

		class ZCORE_API Document : public NonCopyable
		{
			class Init
			{
			public:
				Init();
				virtual ~Init();
			};
		public:
			Document(const char* version = "1.0");
			virtual ~Document();

		public:
			Element*		CreateRootNode(const char* szName);
			//Element*		CreateRootNode(const char* szName, const char* ns_uri, const char* ns_prefix);
			Element*		GetRootNode();

			void			SetKeepBlanks(bool flag);

			z_int32			Load(const char* path);
			z_int32			Save(const char* path, const char* encoding = Z_ENCODING_GBK, z_int32 format = 0);
			void			Close();

		private:
			xmlDocPtr	m_pxDoc;
			std::string	m_strPath;
			xmlChar*	m_pBuffer;

			static Init init_;
		};
	}
}

#endif //__UXML_DOCUMENT_H__
